package tjx.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class DownloadAction extends ActionSupport {
    private String fileName;
    public InputStream getDownloadFile() throws FileNotFoundException
    {
        String path= ServletActionContext.getServletContext().getRealPath( "/download" );
        return new FileInputStream( new File( path,fileName ) );
    }
    public String getFileName() {
        return fileName;
    }
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
    public String download() throws Exception {
        return SUCCESS;
    }
}
